This disclosure relates generally to object initialization in a data processing system and more specifically to serialization of pre-initialized objects in the data processing system.
The Java® programming environment is one example of a managed runtime, which currently lacks a way of specifying array literals (a form of constant) and requires a large amount of execution time to initialize this type of object. There are many objects in Java classes that are essentially constants but typically there is no way to define these objects in a ConstantPool associated with a specific class. (“Java” and all Java-based trademarks and logos are trademarks of Oracle Corporation, and/or its affiliates, in the United States, other countries, or both.)
Lazy initialization as implemented by the Java programming model is typically bug prone and difficult to apply correctly. Current solutions to this type of problem typically hide the data in a class using an initialization on demand holder idiom. The initialization on demand holder utilization is typically a poor solution because the proposed technique requires loading an additional class and is only applicable to use with static fields. See “JSR 133 (Java Memory Model) FAQ”, an article by Jeremy Manson and Brian Goetz dated February, 2004, where this is discussed.
In another example, a double-checked locking idiom is used as a solution, which typically comprises many lines of code and is often implemented incorrectly. However, the pattern, as first introduced, was incorrectly defined and accordingly caused many threading issues. See “The first Drop of Java—Lazy initialization strategies”, an article by Mario Fusco dated Jan. 6, 2009, where this is discussed.
Current solutions create and load constants regardless of whether the constant is actually used. The current solutions typically require additional classes and are therefore heavy weight solutions.